package com.tengju.bff.interfaces.shared;


import com.fasterxml.jackson.annotation.JsonValue;
import com.tengju.data.domain.shared.JsonUtil;
import org.apache.commons.lang3.StringUtils;

/**
 * 前3后4，其余全部加密
 */
public class MobileVO {

    public MobileVO(String mobile) {
        this.mobile = mobile;
    }

    private String mobile;

    @Override
    @JsonValue
    public String toString() {
        if(StringUtils.isNotBlank(mobile)) {
            return mobile.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
        }
        return "";
    }

    public static void main(String[] args) {
        System.out.println(JsonUtil.toJSONString(new MobileVO("13888881238888")));
    }
}

